package com.plwf.lake.controller;

import com.plwf.lake.entity.Subject;
import com.plwf.lake.mapper.SubjectMapper;
import com.plwf.lake.service.SubjectService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
/**
 * 科目口
 * @author ：plwf
 * @time：2019-5-12
 */
@RestController
@RequestMapping("/Subject")
public class SubjectCtrl {

    @Resource
    private SubjectService service;
    private static final Logger log = LoggerFactory.getLogger(Subject.class);
    //删除
    @RequestMapping("/remove/{subId}")
    public boolean remove(@PathVariable("subId") int subId){//从前端传过来的值 ：PathVaribale("subId")
        return service.remove(subId);
    }

    //保存
    @RequestMapping("/save")
    public boolean save(Subject bean){
        try{
            return service.save(bean);
        }catch(Exception ex){
            log.info(ex.getMessage());
            return false;
        }
    }

    //查询所有
    @RequestMapping("/query")
    public List<Subject> query(){
        return service.query();
    }

    //查询单个
    @RequestMapping("/find/{subId}")
    public Subject get(@PathVariable("subId") int subId){
        return service.find(subId);
    }


}
